﻿using System;
using System.Collections.Generic;
using Tools.Extensions;

namespace DL.D_Start_Lite
{
    public class Node<T>
    {
        public T Data { get; set; }
        //计算实际花费
        public Func<Node<T>, Node<T>, float> Cost { get; set; }
        //计算估计花费
        public Func<Node<T>, Node<T>, float> Heuristic { get; set; }

        //起点到该节点的实际成本
        public float G { get; set; }
        //起点到该节点的预计成本
        public float RHS{ get; set; }
        public bool GEqualRHS => G.Approx(RHS);
        //相邻节点
        public List<Node<T>> Neighbor { get; set; } = new();
        
        public Node(T data, Func<Node<T>, Node<T>, float> cost, Func<Node<T>, Node<T>, float> heuristic)
        {
            Data = data;
            Cost = cost;
            Heuristic = heuristic;

            //不连通
            G = float.MaxValue;
            RHS = float.MaxValue;
        }

    }
}